<template>
	<div class="content">
		<el-card class="box-card">
			<div slot="header" class="clearfix">
				<span>基本信息</span>
				<el-button style="float: right;margin-left: 5px;" type="primary" plain @click="go">返 回</el-button>
			</div>
			<div>
				<el-descriptions class="test-report" :column="2"  border>
					<el-descriptions-item label="ID">
						{{form._id || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="项目">
						{{form.project || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="问题类型">
						{{form.problem_type || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="模块">
						{{form.module || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="优先级">
						{{form.priority || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="销售区域">
						{{form.area || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="出现概率">
						{{form.probability || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="类别">
						{{form.type || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="BUG类型">
						{{form.bug_type || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="平台">
						{{form.os || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="固件版本">
						{{form.firmware_version || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="软件版本">
						{{form.software_version || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="米家服务器">
						{{form.service || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="发现版本">
						{{form.discovery_version || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="提交人">
						{{form.submitter || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="处理人">
						{{form.handler || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="抄送人">
						{{form.cc || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="软件版本" span="24">
						{{form.software_version || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="概要" span="24">
						{{form.outline || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="详细描述" span="24">
						{{form.desc || '暂无'}}
					</el-descriptions-item>
					<el-descriptions-item label="附件文档">
						<div v-for="(item,index) in form.doc" :key="index">
							<span @click="doc(item['id'])">文件名：<a :href="item['full_path']" >{{item['file_name']}}</a></span>
						</div>
					</el-descriptions-item>
				</el-descriptions>
				<el-card class="box-card" style="margin-top: 5px;">
					<div slot="header" class="clearfix">
						<span>验证信息</span>
					</div>
					<el-descriptions class="test-report" :column="1" border>
						<el-descriptions-item label="厂家修复信息">
							{{form.correction_content || '暂无'}}
						</el-descriptions-item>
						<el-descriptions-item label="填写人">
							{{getName(form.correction_user_show) || '暂无'}}
						</el-descriptions-item>
						<el-descriptions-item label="填写时间">
							{{getTime(form.correction_date) || '暂无'}}
						</el-descriptions-item>
					</el-descriptions>
				</el-card>
			</div>
		</el-card>
	</div>
</template>

<script>
import { bugId } from '@/api/user'

export default {
	name: 'myPrototype',
	data(){
		return {
			id:'',
			form:{}
		}
	},
	created() {
		this.id = this.$route.params.id
		this.initData(this.id)
	},
	methods:{
		go(){
			this.$router.go(-1)
		},
		initData(data){
			bugId(data).then(res => {
				this.form = Object.assign({},res.data)
			})
		},
		getTime(data){
			if(data != null){
				var d = new Date(data);
				var d2 = d.getTime() - 8 * 60 * 60 * 1000
				d = new Date(d2)
				var  resDate = d.getFullYear() + '-' +
					((d.getMonth() + 1)<10?'0'+(d.getMonth() + 1):(d.getMonth() + 1)) + '-' +
					(d.getDate()<10?'0'+d.getDate():d.getDate())+ ' '+
					(d.getHours()<10?'0'+d.getHours():d.getHours())+':'+
					(d.getMinutes()<10?'0'+d.getMinutes():d.getMinutes())+':'+
					(d.getSeconds()<10?'0'+d.getSeconds():d.getSeconds());
				return resDate
			}else {
				return '暂无'
			}

		},
		getName(data){
			if(data){
				return data['name']
			}else {
				return '暂无'
			}
		},
	}
}
</script>

<style type="scss" scoped>
.content{
	padding: 0 10px;
	margin-top: 10px;
	margin-bottom: 50px;
	min-height: 1000px;
}
/deep/ .el-descriptions-item__label.is-bordered-label {
	font-weight: bold;
	color: #909399;
	background: #fafafa;
	width: 220px;
	text-align: center;
}
</style>
